import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:xvideos/hj_page/mine_business/ai/ai_change_face_page.dart';
import 'package:xvideos/hj_page/mine_business/ai/ai_sub_type/ai_function_Logic.dart';
import 'package:xvideos/hj_page/mine_business/ai/ai_sub_type/ai_strip_sub_page.dart';
import 'package:xvideos/hj_page/mine_business/ai/widget/ai_common_tabbar.dart';
import 'package:xvideos/hj_utils/widget_utils.dart';
import 'package:xvideos/tools_base/widget/keep_alive_widget.dart';

import 'ai_main_logic.dart';

// ai科技首页
class AiPage extends StatelessWidget {
  final int tabIndex; //0-视频换脸 1-图片换脸 2-ai脱衣
  const AiPage({Key? key, this.tabIndex = 0}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GetBuilder<AiLogic>(
      init: AiLogic(tabIndex),
      builder: (controller) {
        return Scaffold(
          appBar: AppBar(
            title: Text('AI科技'),
            toolbarHeight: 44,
            actions: [
              InkWell(
                onTap: () => controller.toAiRecord(context),
                child: Text(
                  "记录",
                  style: TextStyle(
                    color: Colors.white.withOpacity(.45),
                    fontSize: 12,
                  ),
                ),
              ),
              16.sizeBoxW,
            ],
          ),
          body: _buildContent(controller),
        );
      },
    );
  }

  Widget _buildContent(AiLogic controller) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.stretch,
      children: [
        6.sizeBoxH,
        Container(
          height: 30,
          child: AICommonTabbar(
            tabController: controller.tabCtr,
          ),
        ),
        6.sizeBoxH,
        Expanded(
          child: TabBarView(
            controller: controller.tabCtr,
            children: <Widget>[
              AIChangeFacePage(type: 1).keepAlive, //视频换脸
              AIChangeFacePage(type: 0).keepAlive, //图片换脸
              // AIChangeFaceSubPage(type: AIFunctionType.videoChangeFace).keepAlive, //视频换脸
              // AIChangeFaceSubPage(type: AIFunctionType.imageChangeFace).keepAlive, //图片换脸
              AIStripSubPage(type: AIFunctionType.autoStrip).keepAlive,
              //脱衣
            ],
          ),
        ),
      ],
    );
  }
}
